<%--
  Created by IntelliJ IDEA.
  User: 甲乙饼叮叮
  Date: 2019/10/15
  Time: 10:27
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:if test="${medicalVos.pages>1}">
    <div class="container" style="text-align: center;width: 70%">
        <ul class="pagination">
            <li><a href="javascript:goPage(1)">首页</a></li>

                <%--上一页--%>
            <c:if test="${medicalVos.pageNum>1}">
                <li><a href="javascript:goPage(${medicalVos.pageNum-1})">&laquo;</a></li>
            </c:if>
            <c:if test="${medicalVos.pageNum<=1}">
                <li class="disabled"><a>&laquo;</a></li>
            </c:if>

            <!--循环标签显示 - 显示5个
                思路 - 起始值 - 从当前页
            -->
                <%--处理一下最终的页数--%>

            <c:if test="${medicalVos.pageNum+4<medicalVos.pages}">
                <c:set var="startPage" value="${medicalVos.pageNum}"></c:set>
            </c:if>

            <c:if test="${medicalVos.pageNum+4>=medicalVos.pages}">
                <c:set var="startPage" value="${medicalVos.pages-4}"></c:set>
            </c:if>

            <c:forEach begin="${startPage<=0?1:startPage}" end="${startPage+4}" var="n">
                <%--判断当前页是否高亮显示--%>
                <li <c:if test="${medicalVos.pageNum == n}">class='active'</c:if>> <a href="javascript:goPage(${n})">${n}</a></li>
            </c:forEach>


                <%--下一页--%>
            <c:if test="${medicalVos.pageNum<medicalVos.pages}">
                <li><a href="javascript:goPage(${medicalVos.pageNum+1})">&raquo;</a></li>
            </c:if>
            <c:if test="${medicalVos.pageNum>=medicalVos.pages}">
                <li class="disabled"><a>&raquo;</a></li>
            </c:if>

            <li><a href="javascript:goPage(${medicalVos.pages})">尾页</a></li>
            <li><a href="#">当前页${medicalVos.pageNum}/${medicalVos.pages}总页</a></li>

        </ul>
    </div>
</c:if>
<script>
    //    下一页
    function goPage(pageNum){

        //获取每页显示的条数
        var pageSize = 4;

        $("#contents").load("/treatment/personal/medicals",{pageNum:pageNum,pageSize:pageSize});
    }
</script>

